package com.example.administrator.newjiajiesong.main.activity;

import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;

import com.example.administrator.newjiajiesong.R;
import com.example.administrator.newjiajiesong.base.BaseTreeActivity;
import com.example.administrator.newjiajiesong.main.activity.mvp.contract.FindPasswordContract;
import com.example.administrator.newjiajiesong.main.activity.mvp.presenter.FindPasswordPresenterImpl;
import com.example.administrator.newjiajiesong.widget.ClearEditText;


/**
 * FindPasswordActivity
 * (๑• . •๑)
 * 类描述:找回密码
 * Created by LeiXiaoXing on 2017/3/15 18:02
 */

public class FindPasswordActivity extends BaseTreeActivity<FindPasswordContract.View, FindPasswordPresenterImpl> implements FindPasswordContract.View {

    private Button mBtnsendcode;
    private ClearEditText mCetcode;
    private ClearEditText mCetsurepassword;
    private ClearEditText mCetpassword;
    private ClearEditText mCetphone;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_find_password;
    }

    @Override
    protected void initView() {
        setTitleBar(R.id.title_bar, getString(R.string.text_find_password), true, false, false, null);

        mBtnsendcode = (Button) findViewById(R.id.btn_send_code);
        mCetcode = (ClearEditText) findViewById(R.id.cet_code);
        mCetsurepassword = (ClearEditText) findViewById(R.id.cet_sure_password);
        mCetpassword = (ClearEditText) findViewById(R.id.cet_password);
        mCetphone = (ClearEditText) findViewById(R.id.cet_phone);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initEvent() {
        mBtnsendcode.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getPresenter().sendCode();
            }
        });
        findViewById(R.id.btn_sure).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getPresenter().sureEdit();
            }
        });
    }

    @NonNull
    @Override
    public FindPasswordPresenterImpl createPresenter() {
        return new FindPasswordPresenterImpl();
    }

    @Override
    public String getMobile() {
        return mCetphone.getText().toString();
    }

    @Override
    public String getPassword() {
        return mCetpassword.getText().toString();
    }

    @Override
    public String getSurePassword() {
        return mCetsurepassword.getText().toString();
    }

    @Override
    public String getCode() {
        return mCetcode.getText().toString();
    }

    @Override
    public void setCodeBtnEnable(boolean enable) {
        mBtnsendcode.setEnabled(enable);
    }

    @Override
    public void setCodeBtnText(String msg) {
        mBtnsendcode.setText(msg);
    }
}
